package java6681.lesson09;


public class StudyStringBuilder6681 {
    public static void main(String[] args) {
        int n = 8000;
        System.out.println("n="+n);
        testString6681(n);
        testStringBuilder6681(n);
        System.out.println("结束!");
    }

    public static void testString6681(int n) {
        long start = System.currentTimeMillis();
        String str = "";
        for (int i = 0; i < n; i++) {
            str = str + "A";
        }
        long end = System.currentTimeMillis();
        System.out.println("String用时："+(end - start ));
    }
    public static  void testStringBuilder6681(int n){
        long start = System.currentTimeMillis();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < n; i++) {
           builder.append("A");
        }
        long end = System.currentTimeMillis();
        System.out.println("String用时："+(end - start ));
    }

}
